<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core" lang="pt-br">

<f:view>
	<ui:composition template="/template/templatePadrao.xhtml">
		<ui:define name="body">
		
			<h:form id="form_horario">	
				<p:growl id="growl" /> 
				<h:outputText value="Horários" styleClass="breadcrumb"/><br /><br />
				
				<h:panelGroup id="panel_horario">
					<p:panel header="Cadastro">
						<h:panelGrid columns="2">
							<h:outputText value="Título" />
							<h:inputText value="#{horarioManager.horario.titulo}" >
								<f:validateLength minimum="3" maximum="255" />
							</h:inputText >
							
							<h:outputText value="Horário de Entrada" />
							 <p:inputMask id="entrada" value="#{horarioManager.horario.entrada}" mask="99:99">  
				                <f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
				            </p:inputMask>

							<h:outputText value="Horário de Saída para Almoço" />
							<p:inputMask id="saidaAlmoco" value="#{horarioManager.horario.saidaAlmoco}" mask="99:99">  
				                <f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
				            </p:inputMask>
				
							<h:outputText value="Horário de Retorno do Almoço" />
							<p:inputMask id="retornoAlmoco" value="#{horarioManager.horario.retornoAlmoco}" mask="99:99">  
				                <f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
				            </p:inputMask>
				
							<h:outputText value="Horário de Saida " />
							<p:inputMask id="saida" value="#{horarioManager.horario.saida}" mask="99:99">  
				                <f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
				            </p:inputMask>
							
							<h:outputText value="Quantidade de Horas Trabalhadas por Dia" />
							<h:inputText value="#{horarioManager.horario.totalHorasTrabalhadasDia}" />
							
						</h:panelGrid>
						<p:commandButton action="#{horarioManager.save}" value="Salvar" rendered="#{horarioManager.horario.id == null}" update="form_horario,growl"/>
						<p:commandButton action="#{horarioManager.update}" value="Salvar" rendered="#{horarioManager.horario.id != null}" update="form_horario,growl"/>
						
					</p:panel>
				</h:panelGroup>

				<h:panelGroup id="panel_table">
					<p:dataTable value="#{horarioManager.listHorario}" var="es" rows="5" paginator="true"
					emptyMessage="Não existem resultados."
					>
						<p:column headerText="Entrada">
							<h:outputText value="#{es.entrada}">
								<f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
							</h:outputText>
						</p:column>
						<p:column headerText="Saída Almoço">
							<h:outputText value="#{es.saidaAlmoco}">
								<f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
							</h:outputText>
						</p:column>
						<p:column headerText="Retorno Almoço">
							<h:outputText value="#{es.retornoAlmoco}">
								<f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
							</h:outputText>
						</p:column>
						<p:column headerText="Saída">
							<h:outputText value="#{es.saida}">
								<f:convertDateTime locale="pt,BR" timeZone="America/Sao_Paulo" pattern="HH:mm"/>
							</h:outputText>
						</p:column>
						
						<p:column headerText="Qntd Horas">
							<h:outputText value="#{es.totalHorasTrabalhadasDia}" />
						</p:column>
						<p:column headerText="Ação">
							<p:commandButton action="#{horarioManager.prepareUpdate}" value="Atualizar" process="@this" update=":form_horario:panel_horario,:form_horario:growl">
								<f:setPropertyActionListener target="#{horarioManager.horario}" value="#{es}" />
							</p:commandButton>
							<p:commandButton action="#{horarioManager.delete}" value="Excluir" process="@this" update=":form_horario:panel_table,:form_horario:growl">
								<f:setPropertyActionListener target="#{horarioManager.horario}" value="#{es}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</h:panelGroup>
			
			</h:form>
		
		</ui:define>
	</ui:composition>
</f:view>
</html>